import requests

from myUtils import log_save


def myReq(method, url, param, **kwargs):
    """
    重新封装requests请求，默认使用get请求
    """
    r = None
    try:
        if method == 'post':
            r = requests.post(url, param, **kwargs)
        elif method == 'post/json':
            r = requests.post(url, json=param, **kwargs)
        else:
            r = requests.get(url, param, **kwargs)
    except requests.ConnectionError:
        log_save('网络错误', '网络请求超时，请检查网络或稍后再试')
        assert r
    else:
        return r
